<template>
  <div>
    <button @click="submitTogetTokenId">测试1登录获取token&id</button>
    <button @click="submitCheckToken">测试2校验token</button>
  </div>
</template>

<script>
export default {
  name: "axiosTest",
  methods:{
    submitTogetTokenId(){
      axios({
        methods:'POST',
        url:"http://127.0.0.1:8080/test/tosettoken"
      }).then((res)=>{
        let myData = res.data.data;
        let token = myData.token;
        let id = myData.id;
        localStorage.setItem("HOSHINO_T_KK", token);
        localStorage.setItem("USER_ID", id);
      })
    },
    submitCheckToken() {
      axios({
        methods:'POST',
        headers:{
          "HOSHINO_T_KK":localStorage.getItem("HOSHINO_T_KK"),
          "USER_ID":localStorage.getItem("USER_ID")
        },
        url:"http://127.0.0.1:8080/test/interceptor",
      }).then((res)=>{
        console.log(res);
      })
    },
  }
}
</script>

<style>

</style>
